package com.osgi.desktop.ui.plugins;

import com.osgi.desktop.ui.plugins.model.PluginsInstaladosTableModel;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import org.jdesktop.swingx.JXTable;
import org.osgi.framework.Bundle;

public class GerenciarPluginsListener implements MouseListener {
    private BundleSelectionListener bundleSelectionListener;
    public GerenciarPluginsListener(BundleSelectionListener bundleSelectionListener){
        this.bundleSelectionListener = bundleSelectionListener;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        JXTable table = (JXTable)e.getSource();
        int selectedRow = table.getSelectedRow();
        if (selectedRow > -1) {
            PluginsInstaladosTableModel model = (PluginsInstaladosTableModel)table.getModel();
            Bundle bundle = model.getObjectSelected(selectedRow);
            bundleSelectionListener.notifyBundleSelected(bundle);
        }
    }
    @Override
    public void mousePressed(MouseEvent e) {}
    @Override
    public void mouseReleased(MouseEvent e) {}
    @Override
    public void mouseEntered(MouseEvent e) {}
    @Override
    public void mouseExited(MouseEvent e) {}
}
